#include"ShareMemory.hpp"
#include<string.h>
#include"Time.hpp"
#include"Fifo.hpp"
int main()
{
    shm.GetShm();

    shm.AttachShm();
    std::cout << "client attach done" << std::endl;
    //sleep(3);


    //通信
    gpipe1.OpenPipeForWrite();
    struct data *image = (struct data *)shm.GetAddr();
    char ch = 'A';
    while(ch <= 'Z')
    {
        strcpy(image->status, "最新");
        strcpy(image->lasttime, GetCurrTime().c_str());
        strcpy(image->image, "xxxxxxxxxxxxxxxxxxxx");
        gpipe1.Signal();
        std::cout << "Client waiting for writing"<< std::endl;
        gpipe2.Wait();
        sleep(3);
    }



    // char *strinfo = (char*)shm.GetAddr();
    // //std:std::cout << "Please Enter" << std::endl;
    // //scanf("%s",strinfo);

    // char message[16] = "i am process A";
    // for(int i = 0 ; i < sizeof(message) ; i++)
    // {
    //     //sleep(3);
    //     strinfo[i] = message[i];
    // }

    // char ch = 'A';
    // while(ch <= 'Z')
    // {
    //     sleep(3);
    //     strinfo[ch-'A'] = ch;
    //     ch++;
    // }

    shm.DetachShm();
    std::cout << "client detach done" << std::endl;
    //sleep(3);

    
    return 0;
}
